import React, { Component } from 'react'

export default class Test extends Component {
  constructor() {
    super()
    console.log('挂载阶段-constructor')
    this.state = {
      count: 0,
    }
  }
  render() {
    console.log('挂载/更新阶段-render')
    return (
      <div>
        Test,
        <button
          onClick={() => {
            // this.setState({
            //   count: this.state.count + 1,
            // })
            this.forceUpdate()
          }}
        >
          +
        </button>
      </div>
    )
  }
  componentDidMount() {
    console.log('挂载阶段-componentDidMount-- 组件的结构已经渲染到页面上了')
  }

  componentDidUpdate() {
    console.log('更新阶段-componentDidUpdate--组件已经重新渲染完毕')
  }
  componentWillUnmount() {
    console.log('更新阶段-componentWillUnmount--组件即将卸载')
  }
}
